//
//  SegmentControlViewController.m
//  SegmentControl
//

#import "SegmentControlViewController.h"

@implementation SegmentControlViewController

- (void)viewDidLoad {
	
	NSArray *arrSegments = [[NSArray alloc] initWithObjects:
							[NSString stringWithString:@"0"],
							[NSString stringWithString:@"1"],
							[NSString stringWithString:@"2"], nil];
	
	// plain
	UISegmentedControl *mySegmentPlain
	= [[UISegmentedControl alloc] initWithItems:arrSegments];
	[mySegmentPlain setFrame:CGRectMake(10,50,300,40)];
	[mySegmentPlain setSelectedSegmentIndex:0];
	[self.view addSubview:mySegmentPlain];
	[mySegmentPlain release];
	
	UILabel *label = [[UILabel alloc]
					  initWithFrame:CGRectMake(10, 25, 200, 25)];
	label.text = @"Plain:";
	label.backgroundColor = [UIColor clearColor];
	[self.view addSubview:label];
	[label release];

	// bordered
	UISegmentedControl *mySegmentBordered
	= [[UISegmentedControl alloc] initWithItems:arrSegments];
	[mySegmentBordered setFrame:CGRectMake(10,120,300,40)];
	[mySegmentBordered setSegmentedControlStyle:UISegmentedControlStyleBordered];
	[mySegmentBordered setSelectedSegmentIndex:0];
	[self.view addSubview:mySegmentBordered];
	[mySegmentBordered release];
	
	label = [[UILabel alloc]
			 initWithFrame:CGRectMake(10, 95, 200, 25)];
	label.text = @"Bordered:";
	label.backgroundColor = [UIColor clearColor];
	[self.view addSubview:label];
	[label release];
	
	// bar
	UISegmentedControl *mySegmentBar
	= [[UISegmentedControl alloc] initWithItems:arrSegments];
	[mySegmentBar setFrame:CGRectMake(10,190,300,40)];
	[mySegmentBar setSegmentedControlStyle:UISegmentedControlStyleBar];
	[mySegmentBar setSelectedSegmentIndex:0];
	[self.view addSubview:mySegmentBar];
	[mySegmentBar release];
	
	label = [[UILabel alloc]
			 initWithFrame:CGRectMake(10, 165, 200, 25)];
	label.text = @"Bar:";
	label.backgroundColor = [UIColor clearColor];
	[self.view addSubview:label];
	[label release];
	
	[arrSegments release];
}

- (void)dealloc {
    [super dealloc];
}

@end
